package org.dht.com.tra;

import org.dht.com.Observable;
import org.dht.com.msg.Message;
import org.dht.com.util.ThreadCommand;

/**
 * The {@code ReceiverMessageCommand} class, is a Command implementation, that
 * is used for receiving a message and notify to the observer the arrive the
 * message
 */
public class ReceiverMessageCommand extends ThreadCommand {

	/**
	 * The message that has arrived
	 */
	private Message message;

	/**
	 * The observer that is notified for the arrival the message
	 */
	private Observable<Message> observable;

	/**
	 * The constructor of the class. This creates a
	 * {@code ReceiverMessageCommand} instance with the message that arrives and
	 * the observer that has to be notified
	 * 
	 * @param message
	 * @param observer
	 */
	public ReceiverMessageCommand(Message message,
			Observable<Message> observable) {
		this.message = message;
		this.observable = observable;
	}

	/**
	 * Notifies to the observer the arrived message
	 */
	public void run() {
		observable.notifyMessage(message);
	}

}
